{	Problem: http://codeforces.ru/problemset/problem/87/C
 	Verdict: Accepted
}
uses SysUtils, Math;
    
var 
    w,g,was,s:array[0..100010] of longint;
    i,j,n,k,ai,aj,kk:longint;

begin
read(n);
fillchar(was,sizeof(was),0);
fillchar(s,sizeof(s),0);
for i:=1 to n do begin
    w[i]:=0;
    for j:=2 to i do begin
        k:=i-j*(j-1) div 2;
        if k<j then break;
        if k mod j=0 then begin
            ai:=k div j;
            aj:=ai+j-1;
            kk:=s[aj] xor s[ai-1];
      if (kk=0) and (w[i]=0) then w[i]:=j;
            was[kk]:=i; 
        end;
    end;
    g[i]:=0;
    while was[g[i]]=i do inc(g[i]);
    s[i]:=s[i-1] xor g[i];  
end;
if w[n]=0 then write(-1) else write(w[n]);
end.
